unit f_timesh;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxCustomData, cxStyles, cxTL, cxTLdxBarBuiltInMenu,
  cxFilter, cxData, cxDataStorage, cxEdit, Data.DB, cxDBData, dxBar, cxClasses,
  dxStatusBar, dxRibbonStatusBar, cxGridLevel, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
  cxInplaceContainer, cxTLData, cxDBTL, cxMaskEdit, cxMemo;

type
  TForm_timesheet = class(TForm)
    cxDBTreeList1: TcxDBTreeList;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    dxRibbonStatusBar1: TdxRibbonStatusBar;
    dxBarManager1: TdxBarManager;
    dxBarGroup1: TdxBarGroup;
    dxBarManager1Bar1: TdxBar;
    dxBarButton1: TdxBarButton;
    dxBarButton2: TdxBarButton;
    dxBarButton3: TdxBarButton;
    cxGrid1DBTableView1godmesr: TcxGridDBColumn;
    cxGrid1DBTableView1godmesn: TcxGridDBColumn;
    cxGrid1DBTableView1tab_no: TcxGridDBColumn;
    cxGrid1DBTableView1knuz: TcxGridDBColumn;
    cxGrid1DBTableView1cp: TcxGridDBColumn;
    cxGrid1DBTableView1dp: TcxGridDBColumn;
    cxGrid1DBTableView1cf: TcxGridDBColumn;
    cxGrid1DBTableView1df: TcxGridDBColumn;
    cxGrid1DBTableView1summa: TcxGridDBColumn;
    cxDBTreeList1godmesr: TcxDBTreeListColumn;
    cxDBTreeList1root: TcxDBTreeListColumn;
    cxDBTreeList1month_name: TcxDBTreeListColumn;
    dxBarButton4: TdxBarButton;
    cxGrid1DBTableView1Column1: TcxGridDBColumn;
    dxBarButton5: TdxBarButton;
    procedure cxDBTreeList1FocusedNodeChanged(Sender: TcxCustomTreeList;
      APrevFocusedNode, AFocusedNode: TcxTreeListNode);
    procedure dxBarButton4Click(Sender: TObject);
    procedure dxBarButton2Click(Sender: TObject);
    procedure dxBarButton5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form_timesheet: TForm_timesheet;

implementation

uses
  datam, f_timesh_add;
{$R *.dfm}

procedure TForm_timesheet.cxDBTreeList1FocusedNodeChanged
  (Sender: TcxCustomTreeList; APrevFocusedNode, AFocusedNode: TcxTreeListNode);
begin
  dm.q_timesh.Close;
  if AFocusedNode = nil then
    exit;
  dm.q_timesh.Params.ParamByName('atab').AsString :=
    copy(AFocusedNode.Values[2], 1, 5);
  // dm.q_timesh.Params.ParamByName('agodmesr').AsString:=copy(AFocusedNode.Values[1],1,6);
  dm.q_timesh.Open;
  dxBarButton2.Enabled := AFocusedNode.Level = 1;

end;

procedure TForm_timesheet.dxBarButton2Click(Sender: TObject);
begin

  f_timesh_add.T_timesh_add.Create(Self, null);
  // dm.q_timesh.close;
end;

procedure TForm_timesheet.dxBarButton4Click(Sender: TObject);
begin
  dm.proc_recalc_zrl.ParamByName('aym').Value :=
    dm.q_aym.FieldByName('a_ym').Value;
  // dm.proc_recalc_zrl.Active:=true;
  dm.proc_recalc_zrl.Execute;
end;

procedure TForm_timesheet.dxBarButton5Click(Sender: TObject);
begin
  if not dm.q_timesh.Active then
    exit;
  if dm.q_timesh.RecordCount = 0 then
    exit;
  f_timesh_add.T_timesh_add.Create(Self, dm.q_timesh.FieldByName('key').Value);

end;

end.
